package web;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Users {
	public static String getUser(int uid) throws SQLException{
		String uname=new String();
		Dao dao=new Dao();
		ResultSet rs=dao.show("select uname from users where uid="+uid+";");
		while(rs.next()){
			uname=rs.getString("uname");
		}
		dao.close();
		return uname;
	}
	public static String checkUser(int uid) throws SQLException{
		String pword=new String();
		Dao dao=new Dao();
		ResultSet rs=dao.show("select pword from users where uid="+uid+";");
		while(rs.next()){
			pword=rs.getString("pword");
		}
		dao.close();
		return pword;
	}
	public static void addUser(int uid,String uname,String pword){
		Dao dao=new Dao();
		dao.exec("insert into users values(null,"+uid+",'"+uname+"','"+pword+"');");
	}
	public static int checkUname(String uname) throws SQLException{
		int uid=0;
		Dao dao=new Dao();
		ResultSet rs=dao.show("select uid from users where uname='"+uname+"';");
		while(rs.next()){
			uid=rs.getInt("uid");
		}
		dao.close();
		return uid;
	}
}
